﻿using System.Windows.Threading;

namespace Requestor.TestApp
{
    public class ParameterViewModel : ViewModelBase
    {
        public string Key
        {
            get { return _key; }
            set
            {
                _key = value;
                OnPropertyChanged("Key");
            }
        }
        private string _key;

        public string Value
        {
            get { return _value; }
            set
            {
                _value = value;
                OnPropertyChanged("Value");
            }
        }
        private string _value;

        public ParameterViewModel(Dispatcher dispatcher)
            : base(dispatcher)
        {
            AddCommand = new DelegateCommand(Add, CanAdd);
        }

        #region AddCommand

        public DelegateCommand AddCommand { get; private set; }

        private void Add(object sender)
        {
            MainViewModel.This.Data.Add(string.Format("{0}={1}", Key, Value));
            Key = null;
            Value = null;
        }

        private bool CanAdd(object sender)
        {
            return true;
        }

        #endregion
    }
}